-- collect_energy
-- created by chendh
-- 收集能量

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    -- 受创触发
    trigger = function(who, prop, arg)
        local attrib = "energy";
        local cur_value = who.dbase:query(attrib, 0);
        local dbase = MonsterM.query(who.dbase:query("class_id"), "dbase");

        local max_value = dbase["max_energy"] or 100;

        local add_num = math.min(prop[3], max_value - cur_value);

        who.dbase:set(attrib, cur_value + add_num);

        EventMgr.fire(event.COLLECT_ENERGY, {["amount"] = add_num, ["pos"] = who:getPos(), ["attrib"] = attrib });

        return true;
    end,

    record = function(target, prop, path)
        return false;
    end
};